//
//  LMLiveScoreViewController.m
//  彩票
//
//  Created by apple on 15/9/26.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "LMLiveScoreViewController.h"

@interface LMLiveScoreViewController()

@property (nonatomic,weak)UITextField *field;
@property (nonatomic,assign)BOOL startField;

@end

@implementation LMLiveScoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UITextField *field = [[UITextField alloc] init];
    UIDatePicker *datePicker = [[UIDatePicker alloc] init];
    datePicker.datePickerMode  = UIDatePickerModeTime;
    
    datePicker.locale = [NSLocale localeWithLocaleIdentifier:@"ZH"];
    field.inputView  = datePicker;
    [self.tableView addSubview:field];
    self.field =field;
    
    [datePicker addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventValueChanged];
    
    

    LMSettingObject *item1 = [LMSettingObject SettingObjectWithIcon:nil title:@"提醒我关注的比赛" type:@"0"];
    LMSettingObjectGroup *group1 = [[LMSettingObjectGroup alloc] init];
    group1.items  = @[item1];
    group1.footTitle =@"当我关注的比赛比分发生变化时，通过小弹窗或者推送进行提醒";
    [self.settingitemArray addObject:group1];
    
    
    
    LMSettingObject *item2 = [LMSettingObject SettingObjectWithIcon:nil title:@"起始时间" type:@"2"];
    
    item2.operationBlock =^{
      
        self.startField = YES;
        [self.field becomeFirstResponder];
    };
    
    
    LMSettingObjectGroup *group2= [[LMSettingObjectGroup alloc] init];
    group2.items  = @[item2];
    group2.headTitle =@"只在以下时间接受比分直播";
    [self.settingitemArray addObject:group2];
    
    
    LMSettingObject *item3 = [LMSettingObject SettingObjectWithIcon:nil title:@"结束时间" type:@"2"];
    
    item3.operationBlock =^{
        self.startField = NO;
        [self.field becomeFirstResponder];
        
        [UIView beginAnimations:nil context:nil];
        self.tableView.contentOffset = CGPointMake(0, 60);
        [UIView commitAnimations];
    };
    
    
    LMSettingObjectGroup *group3= [[LMSettingObjectGroup alloc] init];
    group3.items  = @[item3];
    
    [self.settingitemArray addObject:group3];

}

- (void)valueChange:(UIDatePicker *) datePicker{
  
    NSDate *date =datePicker.date;
    NSDateFormatter  *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"HH:mm";
    
    if (self.startField) {
        NSLog(@"=============%@",[formatter stringFromDate:date]);
    }
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
    [self.view endEditing:YES];
}


@end
